.pagination {
  .btn {
    border-left: 1px solid $body-bg;
    border-right: 1px solid $body-bg;
    flex-grow: 0;
    padding-left: 15px;
    padding-right: 15px;
    transition: none;

    &.page-count {
      padding-right: 5px;
    }

    &.page-count-dropdown {
      padding-left: 5px;
    }

    &:first-child {
      border-left: none;
      border-right: none;
    }

    &:last-child {
      border-right: none;
    }
  }

  .page-count-container .btn {
    border-radius: 0;
  }
}

.center-text {
  text-align: center;
}

.display-mode-select {
  padding-left: 0.375rem;
  padding-right: 0.375rem;
  text-wrap: nowrap;

  > svg:first-child {
    margin-right: 0;
  }
}

.display-mode-menu {
  .dropdown-item {
    color: #f5f8fa;
    font-size: 1rem;

    &:hover {
      background-color: rgba(138, 155, 168, 0.15);
      cursor: pointer;
    }
  }

  .zoom-slider-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0.5rem;
    min-height: 1rem;
    padding-bottom: 0.5rem;
    padding-top: 0.25rem;
  }

  .zoom-slider {
    &::-webkit-slider-thumb {
      background-color: $primary;
    }

    &::-webkit-slider-runnable-track {
      background-color: $body-bg;
    }

    &:focus::-webkit-slider-runnable-track {
      background-color: lighten($body-bg, 5%);
    }

    &::-moz-range-thumb {
      background-color: $primary;
    }

    &::-moz-range-track {
      background-color: $body-bg;
    }

    &:focus::-moz-range-track {
      background-color: lighten($body-bg, 5%);
    }
  }
}

// hide zoom slider in xs viewport
@include media-breakpoint-down(xs) {
  .display-mode-menu .zoom-slider-container,
  .zoom-slider-container {
    display: none;
  }
}

.display-mode-popover {
  padding-left: 0;
  padding-right: 0;
}

input[type="range"].zoom-slider {
  height: 100%;
  margin: 0;
  max-width: 60px;
  padding-left: 0;
  padding-right: 0;

  // width is set to 100% by default, but in a flex container, it gets a very small width
  width: unset;
}

.query-text-field-group {
  align-items: stretch;
  display: flex;
  flex-wrap: wrap;
  position: relative;
}

.query-text-field {
  border: 0;
  width: 50%;
}

.query-text-field-clear {
  background-color: $secondary;
  color: $text-muted;
  font-size: $btn-font-size-sm;
  margin: $btn-padding-y $btn-padding-x;
  padding: 0;
  position: absolute;
  right: 0;
  z-index: 4;

  &:hover,
  &:focus,
  &:active,
  &:not(:disabled):not(.disabled):active,
  &:not(:disabled):not(.disabled):active:focus {
    background-color: $secondary;
    border-color: transparent;
    box-shadow: none;
  }
}

.saved-filter-list-menu {
  width: 300px;

  &.dropdown-menu.show {
    display: flex;
    flex-direction: column;
  }

  .set-as-default-button {
    float: right;
    margin-right: 0.5rem;
    padding: 0.25rem 0.5rem;
    width: auto;
  }

  .LoadingIndicator {
    height: auto;
    text-align: center;

    .spinner-border {
      height: 1.5rem;
      width: 1.5rem;
    }
  }
}

.saved-filter-list {
  list-style: none;
  margin-bottom: 0.25rem;
  max-height: 230px;
  overflow-y: auto;
  padding-left: 0;

  .dropdown-item-container {
    display: flex;

    .dropdown-item {
      align-items: center;
      color: $text-color;
      display: inline;
      overflow-x: hidden;
      padding-left: 1.25rem;
      padding-right: 0.25rem;
      text-overflow: ellipsis;

      &:focus,
      &:hover {
        background-color: #8a9ba826;
        cursor: pointer;
      }
    }

    .btn-group {
      margin-left: auto;

      .btn {
        border-radius: 0;
      }
    }

    .delete-button {
      color: $danger;
    }
  }
}

.sidebar-saved-filter-list-container .toolbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;

  .btn {
    font-weight: bold;
  }
}

.sidebar-saved-filter-list-container {
  .label-group {
    align-items: center;
    display: flex;
    overflow: hidden;
  }

  .saved-filter-item {
    cursor: pointer;
    height: 2em;
    margin-bottom: 0.25rem;

    a {
      align-items: center;
      display: flex;
      height: 2em;
      justify-content: space-between;
      outline: none;

      &:hover,
      &:focus-visible {
        background-color: rgba(138, 155, 168, 0.15);
      }

      .selected-object-label,
      .excluded-object-label {
        font-size: 16px;
      }
    }

    .label-group {
      align-items: center;
      display: flex;
      overflow: hidden;

      .selected {
        font-weight: bold;
      }

      .fa-icon {
        flex-shrink: 0;
      }
    }

    .delete-button {
      color: $danger;
    }
  }

  .saved-filter-search-input {
    margin-bottom: 0.5rem;
  }
}

.save-filter-dialog {
  .existing-filter-list {
    max-height: 300px;
    overflow-y: auto;
  }
}

.save-filter-button {
  color: $text-color;
}

.saved-filter-overwrite-warning {
  color: $danger;
  font-weight: bold;
}

.edit-filter-dialog .rating-stars {
  font-size: 1.3em;
  margin-left: 0.25em;
}

.rating-filter .and-divider {
  margin-left: 0.5em;
}

.edit-filter-dialog {
  .modal-header {
    align-items: center;
    padding: 0.5rem 1rem;

    .search-input {
      width: auto;
    }
  }

  .modal-body {
    max-height: min(550px, calc(100vh - 12rem));
    padding-left: 0;
    padding-right: 0;
  }

  .modal-footer {
    justify-content: space-between;

    > div > :not(:first-child) {
      margin-left: 0.25rem;
    }
  }

  .search-term-row {
    align-items: center;
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    margin-left: 1.5rem;
    margin-right: 1rem;

    .search-term-input {
      flex-basis: 75%;
    }

    @include media-breakpoint-down(xs) {
      flex-wrap: wrap;

      > span {
        width: 100%;
      }

      .search-term-input {
        flex-basis: 100%;
      }
    }
  }

  .filter-tags {
    border-top: 1px solid rgb(16 22 26 / 40%);
    padding: 1rem 1rem 0 1rem;
  }

  .criterion-list {
    flex-direction: column;
    flex-wrap: nowrap;

    .pinned-criterion-divider {
      padding-bottom: 2.5rem;
    }

    .card {
      border: 1px solid rgb(16 22 26 / 40%);
      box-shadow: none;
      margin: 0 0 -1px;
      padding: 0;

      .collapse-icon {
        margin-left: 0;
      }

      .filter-item-header {
        background-color: $card-cap-bg;
        border: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.125);
        color: inherit;
        cursor: pointer;
        display: flex;
        margin-bottom: 0;
        padding: 0.75rem 1.25rem;

        &:focus {
          border-color: $primary;
          border-radius: calc(0.375rem - 1px);
          box-shadow: inset 0 0 0 0.1rem rgba(19, 124, 189);
          outline: 0;
        }
      }
    }

    .filter-item-header .btn {
      border: 0;
      padding-bottom: 0;
      padding-top: 0;
    }

    .pin-criterion-button {
      color: $text_color;

      &:hover svg {
        transform: rotate(0);
      }
    }

    .remove-criterion-button {
      color: $danger;
    }
  }

  .edit-filter-right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-left: 1rem;
    padding-right: 1rem;
    width: 100%;
  }
}

.modifier-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.modifier-options .modifier-option {
  background-color: $secondary;
  border: none;
  border-radius: 10rem;
  cursor: pointer;
  display: inline-block;
  font-size: 100%;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.5rem;
  margin-right: 0.25rem;
  padding: 0.25em 0.6em;
  text-align: center;
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
    border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  vertical-align: baseline;
  white-space: nowrap;

  &.selected {
    background-color: $primary;
  }
}

.filter-tags {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;

  .more-tags {
    background-color: transparent;
    color: #fff;
  }

  .clear-all-button {
    color: $text-color;
    // to match filter pills
    line-height: 16px;
    padding: 0;
  }
}

.filter-button {
  position: relative;

  .fa-icon {
    margin: 0;
  }

  .badge {
    font-size: 60%;
    position: absolute;
    right: 0;

    // button group has a z-index of 1
    z-index: 2;
  }
}

.filter-visible-button {
  padding-left: 0.3rem;
  padding-right: 0.3rem;

  &:focus:not(.active):not(:hover) {
    background: none;
  }

  &:focus,
  &.active:focus {
    box-shadow: none;
  }
}

.selectable-filter ul {
  list-style-type: none;
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  // to prevent unnecessary vertical scrollbar
  padding-bottom: 0.15rem;
  padding-inline-start: 0;

  .modifier-object {
    font-style: italic;

    .selected-object-label,
    .unselected-object-label {
      opacity: 0.6;
    }
  }

  .unselected-object {
    opacity: 0.8;
  }

  .selected-object,
  .excluded-object,
  .unselected-object {
    cursor: pointer;
    height: 2em;
    margin-bottom: 0.25rem;

    a {
      align-items: center;
      display: flex;
      height: 2em;
      justify-content: space-between;
      outline: none;

      &:hover,
      &:focus-visible {
        background-color: rgba(138, 155, 168, 0.15);
      }

      .selected-object-label,
      .excluded-object-label {
        font-size: 16px;
      }
    }

    .include-button {
      color: $success;
    }

    .exclude-icon {
      color: $danger;
    }

    .exclude-button {
      align-items: center;
      display: flex;
      margin-left: 0.25rem;
      padding-left: 0.25rem;
      padding-right: 0.25rem;

      .exclude-button-text {
        color: $danger;
        display: none;
        font-size: 12px;
        font-weight: 600;
      }

      &:hover {
        background-color: inherit;
      }

      &:hover .exclude-button-text,
      &:focus .exclude-button-text {
        display: inline;
      }
    }

    .object-count {
      color: $text-muted;
      font-size: 12px;
    }
  }

  .selected-object:hover,
  .selected-object a:focus-visible,
  .excluded-object:hover,
  .excluded-object a:focus-visible {
    .include-button,
    .exclude-icon {
      color: #fff;
    }
  }
}

// used to align list text without icons to those that do
.sidebar .no-icon-margin {
  // icon width is 17.5px + 5.6px margin each side
  margin-left: 28.7px;
}

.sidebar-list-filter .clearable-input-group {
  margin-bottom: 0.5rem;
}

.sidebar-list-filter ul {
  list-style-type: none;
  margin-bottom: 0.25rem;
  max-height: 300px;
  overflow-y: auto;
  // to prevent unnecessary vertical scrollbar
  padding-bottom: 0.15rem;
  padding-inline-start: 0;

  .modifier-object {
    font-style: italic;

    .selected-object-label,
    .unselected-object-label {
      opacity: 0.6;
    }
  }

  .unselected-object {
    opacity: 0.8;
  }

  .selected-object,
  .excluded-object,
  .unselected-object {
    cursor: pointer;
    height: 2em;
    margin-bottom: 0.25rem;

    a {
      align-items: center;
      display: flex;
      height: 2em;
      justify-content: space-between;
      outline: none;

      &:hover,
      &:focus-visible {
        background-color: rgba(138, 155, 168, 0.15);
      }

      .selected-object-label,
      .excluded-object-label {
        font-size: 16px;
      }
    }

    .include-button {
      color: $success;

      &.single-value {
        visibility: hidden;
      }
    }

    .exclude-icon {
      color: $danger;
    }

    .exclude-button {
      align-items: center;
      display: flex;
      margin-left: 0.25rem;
      padding-left: 0.25rem;
      padding-right: 0.25rem;

      .exclude-button-text {
        color: $danger;
        display: none;
        font-size: 12px;
        font-weight: 600;
      }

      &:hover {
        background-color: inherit;
      }

      &:hover .exclude-button-text,
      &:focus .exclude-button-text {
        display: inline;
      }
    }

    .object-count {
      color: $text-muted;
      font-size: 12px;
    }
  }

  .selected-object:hover,
  .selected-object a:focus-visible,
  .excluded-object:hover,
  .excluded-object a:focus-visible {
    .include-button,
    .exclude-icon {
      color: #fff;
    }
  }

  .selected-object,
  .unselected-object {
    .label-group {
      align-items: center;
      display: flex;
      overflow: hidden;
    }
  }
}

.sidebar-list-filter > .extra {
  padding-top: 0.25rem;
}

.sidebar-list-filter .extra {
  min-height: 2em;
}

.tilted {
  transform: rotate(45deg);
}

.table-list {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  margin-bottom: 1rem;
  margin-left: 0;
  margin-right: 0;
  max-height: 78dvh;
  min-width: min-content;
  overflow-x: auto;
  position: relative;

  table {
    margin: 0;

    thead {
      background-color: #202b33;
      position: sticky;
      top: 0;
      z-index: 1;
    }

    td:first-child {
      padding: 0;
    }

    label {
      margin: 0;
      padding: 0.5rem;
    }
  }

  .column-select {
    margin: 0;
    padding: 7px;
  }

  .select-col {
    width: 20px;
  }

  .comma-list {
    list-style: none;
    margin: 0;
    padding: 4px 2px;

    li {
      display: inline;
    }

    li::after {
      content: ", ";
    }

    li:last-child::after {
      content: "";
    }
  }

  .newline-list {
    list-style: none;
    margin: 0;
    padding: 4px 2px;

    li {
      display: inline;
      white-space: pre-wrap;
    }

    li::after {
      content: "\A";
    }

    li:last-child::after {
      content: "";
    }
  }

  .newline-list.overflowable,
  .comma-list.overflowable {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .comma-list.overflowable {
    width: 190px;
  }

  .newline-list.overflowable {
    -webkit-line-clamp: 1;
    width: 700px;
  }

  .newline-list.overflowable:hover,
  .comma-list.overflowable:hover {
    background: #28343c;
    border: 1px solid #414c53;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.28);
    display: block;
    height: auto;
    margin-left: -0.4rem;
    margin-top: -0.9rem;
    overflow: hidden;
    padding: 0.1rem 0.5rem;
    position: absolute;
    top: auto;
    white-space: normal;
    width: max-content;
    z-index: 100;
  }

  .comma-list.overflowable:hover {
    max-width: 40rem;
  }

  .newline-list.overflowable li .ellips-data:hover,
  .comma-list.overflowable li .ellips-data:hover {
    max-width: fit-content;
  }

  td {
    color: hsla(0, 0%, 100%, 0.6);
    font-weight: 500;
    position: relative;
    text-align: left;
    white-space: nowrap;

    .ellips-data {
      display: block;
      max-width: 190px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .star-rating-number {
      display: none;
    }

    a {
      font-weight: 600;
      white-space: nowrap;
    }
  }

  td.select-col {
    text-align: center;
  }

  .table thead th {
    border: none;
    white-space: nowrap;
  }

  tr {
    border-collapse: collapse;
  }

  .date-head {
    width: 97px;
  }
}

.table-list tbody tr:hover {
  background-color: #2d3942;
}

.table-list a {
  color: $text-color;
}

.table-list .table-striped td,
.table-list .table-striped th {
  font-size: 1rem;
  vertical-align: middle;

  h5,
  h6 {
    font-size: 1rem;
  }

  &:first-child {
    border-left: none;
  }
}

.filtered-list-toolbar {
  align-items: center;
  background-color: $body-bg;
  gap: 0.5rem;
  justify-content: center;

  // offset the main padding
  margin-top: -0.5rem;
  padding-bottom: 0.5rem;
  padding-top: 0.5rem;

  & > .btn-group {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 0.5rem;

    &:first-child {
      justify-content: flex-start;
    }

    &:last-child {
      justify-content: flex-end;
    }
  }

  // set the width of the zoom-slider-container to prevent buttons moving when
  // the slider appears/disappears
  .zoom-slider-container {
    min-width: 60px;
  }
}

.custom-field-filter {
  align-items: center;
  display: flex;

  > div:first-child {
    flex-grow: 1;
  }

  .custom-field-filter-buttons {
    display: flex;
    flex-direction: column;
    margin-left: 0.25rem;

    .btn {
      border-radius: 0.2rem;
      font-size: 0.875rem;
      line-height: 1.5;
      padding: 0.25rem 0.5rem;

      &:first-child {
        margin-bottom: 0.25rem;
      }
    }
  }
}

.item-list-container .sidebar-pane {
  width: 100%;
}

.sidebar {
  .sidebar-search-container {
    display: flex;
    margin-bottom: 0.5rem;
  }

  .search-term-input {
    flex-grow: 1;
    margin-right: 0;

    .clearable-text-field {
      height: 100%;
    }
  }

  .edit-filter-button {
    width: 100%;
  }

  .sidebar-footer {
    background-color: $body-bg;
    bottom: 0;
    display: none;
    padding: 0.5rem;
    position: sticky;

    @include media-breakpoint-down(xs) {
      display: flex;
      justify-content: center;
    }
  }
}

@include media-breakpoint-down(xs) {
  .sidebar .sidebar-search-container {
    margin-top: 0.25rem;
  }
}

.pagination-footer-container {
  background-color: transparent;
  bottom: $navbar-height;
  position: sticky;
  z-index: 10;

  @include media-breakpoint-up(sm) {
    bottom: 0;
  }
}

.pagination-footer {
  margin: auto;
  padding: 0.5rem 1rem 0.75rem;

  width: fit-content;

  .pagination.btn-group {
    box-shadow: 0 8px 10px 2px rgb(0 0 0 / 30%);
  }

  .pagination {
    margin-bottom: 0;

    .btn:disabled {
      color: #888;
      opacity: 1;
    }
  }
}

// on very large screens, offset the margins to center the pagination controls
@media (min-width: 1800px) {
  .sidebar-pane:not(.hide-sidebar) {
    .filter-tags,
    .pagination-index-container,
    .pagination-footer-container {
      margin-left: -$sidebar-width;
      margin-right: 0;
    }
  }
}

// hide sidebar Edit Filter button on larger screens
@include media-breakpoint-up(md) {
  .sidebar .edit-filter-button {
    display: none;
  }
}

// hide the search input field if the sidebar is open on smaller screens
@media (min-width: 576px) and (max-width: 1400px) {
  .sidebar-pane:not(.hide-sidebar) .filtered-list-toolbar .search-term-input {
    display: none;
  }
}

#more-criteria-popover {
  box-shadow: 0 8px 10px 2px rgb(0 0 0 / 30%);
  max-width: 400px;
  padding: 0.25rem;
}

// Duration slider styles
.duration-slider,
.age-slider-container {
  padding: 0.5rem 0 1rem;
  width: 100%;
}

.duration-label-input,
.age-label-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  color: $text-color;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.125rem 0.25rem;
  width: 4rem;

  &:hover {
    border-color: $secondary;
  }

  &:focus {
    border-color: $primary;
    outline: none;
  }
}

.duration-preset {
  cursor: pointer;
}

.selected-items-info {
  align-items: center;
  border: 1px solid $secondary;
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.scene-list-toolbar .selected-items-info {
  justify-content: flex-start;
}

// modify margins for toolbar within sidebar pane to accommodate toggle button
.sidebar-pane .filtered-list-toolbar {
  margin-left: 40px;
  margin-right: 40px;
}

// on very large screens, offset the margins to center the toolbar
@media (min-width: 1800px) {
  .sidebar-pane:not(.hide-sidebar) {
    .filtered-list-toolbar {
      margin-left: -$sidebar-width;
      margin-right: 0;
    }
  }
}

.item-list-container .filtered-list-toolbar.has-selection {
  border-radius: 0.5rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  position: sticky;
  top: $navbar-height;
  width: fit-content;
  z-index: 10;

  @include media-breakpoint-down(xs) {
    top: 0;
  }
}

.detail-body .filtered-list-toolbar.has-selection {
  top: calc($sticky-detail-header-height + $navbar-height);

  @include media-breakpoint-down(xs) {
    top: 0;
  }
}
